Function.prototype.zhapply = function (thisArg, argArray = []) {
  console.log("zhapply被调用了", this, thisArg, argArray);

  var fn = this;
  thisArg = thisArg ? Object(thisArg) : window;
  thisArg.fn = fn;
  var result = thisArg.fn(...argArray);
  delete thisArg.fn;
  return result;
};

function sum(num1, num2) {
  console.log("sum被调用了", this, num1, num2);
  return num1 + num2;
}

// const result = sum.apply("apply", [12, 23]);
//通过隐式绑定this指向到sum， 然后调用zhapply函数获取到的this是就是sum函数， 然后将thisArg变为object，然后调用fn函数， 隐式绑定this到thisArg， 然后删除thisArg的fn，但会result。
const result = sum.zhapply("apply");
